package top.iridescent.gateway.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import top.iridescent.gateway.common.Constant;
import top.iridescent.gateway.dao.GatewayLogCfgDao;
import top.iridescent.gateway.entity.GatewayLogCfg;

import java.util.ArrayList;
import java.util.List;

@Service("gatewayLogCfgService")
public class GatewayLogCfgService extends ServiceImpl<GatewayLogCfgDao, GatewayLogCfg> {

    public List<GatewayLogCfg> getEnableUrl() {
        List<GatewayLogCfg> list;
        try {
            QueryWrapper<GatewayLogCfg> queryWrapper = new QueryWrapper();
            List<String> tmp=new ArrayList<>();
            tmp.add(Constant.ULR_FUNCTION_TYPE_DELETE);
            tmp.add(Constant.ULR_FUNCTION_TYPE_UPDATE);
            tmp.add(Constant.ULR_FUNCTION_TYPE_INSERT);
            queryWrapper.lambda().eq(GatewayLogCfg::getStatus, Constant.GATEWAY_LOG_ENABLE).in(GatewayLogCfg::getType,tmp);
            list = list(queryWrapper);
        } catch (Exception e) {
            log.error("获取log_url配置信息失败,error:", e);
            list = new ArrayList<>();
        }
        return list;
    }

}
